package daily.may0528;

class MyThread3 extends Thread {
    @Override
    public void run() {
        System.out.println(getName() + "线程开始执行");
    }

    //构造方法：指定线程名称
    public MyThread3(String name) {
        super(name);
    }

    public MyThread3() {
    }
}

public class SetThreadNameTest {
    public static void main(String[] args) {
        //构造方法传入线程名称
        new MyThread3("XHH").start();
        //setName方法指定线程名称
        MyThread3 myThread = new MyThread3();
        myThread.setName("YDD");
        myThread.start();
    }
}
